﻿using System.Net;

namespace PlaxoSyncWM {
    public class Net {
        private const string URL = "http://www.google.com";

        public bool DetectInternet() {
            HttpWebRequest req = null;
            HttpWebResponse resp = null;
            bool retValue = false;

            try {
                req = (HttpWebRequest) HttpWebRequest.Create(URL);
                resp = (HttpWebResponse) req.GetResponse();
                if (resp.StatusCode == HttpStatusCode.OK)
                    retValue = true;
                else
                    retValue = false;
                req = null;
                resp.Close();
                resp = null;
            }
            catch {
                retValue = false;
            }

            return retValue;
        }
    }
}